#include "widget.h"
#include "ui_widget.h"
#include <fstream>
#include <QDebug>
#include <QIcon>
#include <QFile>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    this->setWindowIcon(QIcon(R"(:/blue.jpg)"));
    QFile file(R"(:/index.txt)");
//    std::ifstream ifs("D:/code/qt project/QComboBox_text/index.txt");

    if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        qDebug() << "打开失败：" << file.errorString();
        return;
    }

    QTextStream in(&file);
    QString str = in.readLine();
    ui->comboBox_eat->addItem(str);
    ui->comboBox_drank->addItem(str);
    file.close();
}

Widget::~Widget()
{
    delete ui;
}

